home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / tex-bnf / bnf.bugs (.txt) < prev    next >
LaTeX Document  |  1993-11-07  |  6KB  |  143 lines

  1. 1). The BNF macros cannot deal with environments that are started by one of
  2. the optional parameters and ended by another. For example the following
  3. example (due to Florence Maraninchi of LGI-IMAG Campus, BP 53X, 38041
  4. Grenoble cedex, FRANCE) does not work.
  5. This is a structural problem, that I do not have time to consider at the
  6. moment. If anyone else solves it, will they please let me know?
  7. ________________________________________________________________________________
  8. \newenvironment{tabu}{\begin{tabular}{ll}[t]}{\end{tabular}}
  9. \begin{grammar}
  10.         [(colon){\begin{tabu} : & }]
  11.         [(period){\end{tabu}}]
  12.         [(semicolon){\\ $\mid$ &  }]
  13.         [(comma){  }]
  14.         [(quote){\begin{bf}}{\end{bf}}]
  15.         toto : expression.
  16.         expression: constante; idf;expression operateur expression.
  17.         operateur: "+" ; "-" ; "*" ; "/".
  18.         constante: "0" ; "1" ; "2" ; "3" ; "4".
  19. \end{grammar}
  20. ________________________________________________________________________________
  21. 2). The above example also made me aware of another problem that has
  22. not yet been reported. If you try and include a command with an optional
  23. parameter in one of the optional parameters of the grammar environment,
  24. LaTeX will get horribly confused. For example, a grammar environment
  25. such as
  26. --------------------------------------------------------------------------------
  27. \begin{grammar}
  28.          [(colon){\rule[.5\lineskip]{10pt}{\lineskip}}]
  29.  wrong : won't work.
  30. \end{grammar}
  31. won't work. This is due to TeX' macro expansion mechanism, and an
  32. elegant solution would require a fairly major overhaul, which I don't
  33. have time for at the moment.
  34. A hack is to change the syntax of the optional commands of the grammar
  35. environment so that the optional commands are delimited by some other
  36. symbol than "[" and "]". If, for example, we were to choose "!" as our
  37. (left _and_ right) delimiter, then lines 63, 65, 66 and 69 of the 
  38. original BNF macros would have to be changed. They are currently
  39. ...............................................................................
  40. \def\@dogrammarchars{
  41.   \@ifnextchar [{\@getchardef}{\@defaultchardefs}}
  42. \def\@getchardef[(#1)#2]{
  43.   \@dogrammarchar{#1}[#2]
  44.   \@dogrammarchars}
  45. \def\@dogrammarchar#1[#2]{
  46.   \csname if@#1\endcsname\else
  47.   \csname @def#1\endcsname{#2}\csname @#1true\endcsname\fi}
  48. ...............................................................................
  49. and would have to become
  50. ................................................................................
  51. \def\@dogrammarchars{
  52.   \@ifnextchar !{\@getchardef}{\@defaultchardefs}}
  53. %              ^
  54. \def\@getchardef!(#1)#2!{
  55. %               ^      ^
  56.   \@dogrammarchar{#1}!#2!
  57. %                    ^  ^
  58.   \@dogrammarchars}
  59. \def\@dogrammarchar#1!#2!{
  60. %                    ^  ^
  61.   \csname if@#1\endcsname\else
  62.   \csname @def#1\endcsname{#2}\csname @#1true\endcsname\fi}
  63. ................................................................................
  64. (sorry to belabour the obvious, but to be on the safe side, the "^" are
  65. only to indicate where the changes have taken place)
  66. The optional parameters may not now contain any "!" symbols, or else
  67. we're back where we started from.
  68. 3). Thanks to David Wright (wright@tasis.eecs.utas.edu.au) and Arto
  69. Viitanen (av@uta.fi) for the next one.
  70. I included a couple of spaces in the BNF macros, where I shouldn't have,
  71. which leads to spurious spaces being produced in the output. (Dave
  72. Wright's example was "->" appearing as "- >", and Arto Viitanen's was 
  73. "<terminal>" appearing as "<terminal >". The solution is to remove the
  74. extra spaces, on lines 22 and 24. These were
  75. ................................................................................
  76.     \catcode`\<\active
  77.     \def<{{\@deactifygrammarchars \@first#1}}
  78. %                                ^
  79.     \catcode`\>\active
  80.     \def>{{\@deactifygrammarchars \@second#1}}}
  81. %                                ^
  82. \endgroup
  83. ................................................................................
  84. The "^" symbols indicate the spaces that should be removed.
  85. 4) The following is due to Craig Brown (cmb@research.canon.oz.au) at
  86. Canon Information Systems Research Australia.  This bug was the result
  87. of my ignorance of the subtleties of TeX's input mechanism.
  88. Just another comment regarding your Context Free Grammar.
  89. This works:
  90. \newenvironment{tligrammar}%
  91. {\begin{grammar}%
  92. [(nonterminal){\begin{bf}}{\end{bf}}]%
  93. [(colon){ ::=}]%
  94. [(comma){~}]%
  95. [(semicolon){ $|$}]}%
  96. {\end{grammar}}
  97. \begin{tligrammar}
  98. <A>: <B>, <C>, <D>.
  99. \end{tligrammar}
  100. and this does not:
  101. \begin{grammar}
  102. [(nonterminal){\begin{bf}}{\end{bf}}]
  103. [(colon){ ::=}]
  104. [(comma){~}]
  105. [(semicolon){ $|$}]
  106. <A>: <B>, <C>, <D>.
  107. \end{grammar}
  108. Conclusion: Latex is black magic!
  109. Regards, Craig Brown.
  110. Craig Brown                                  | cmb@research.canon.oz.au 
  111. Canon Information Systems Research Australia | Phone +61-2-805-2900 
  112. PO Box 313 NORTH RYDE NSW 2113               | Fax   +61-2-805-2929
  113. 5) The following major bug (what an embarassment) was found by Mark van
  114. den Brand at the University of Nijmegen.  I can't understand that nobody,
  115. including myself, found it earlier.
  116. If the left hand side is repeated in alternative production rules
  117. seperated by semicolons, the result is not what one would want.
  118. For example;
  119. \begin{grammar}
  120. rule:
  121.     first alternative;
  122. rule:
  123.     second alternative.
  124. \end{grammar}
  125. is printed more or less as
  126. rule:
  127.     first alternative;
  128.     rule:
  129.     second alternative.
  130. Although this sort of construction may not be used very often when
  131. writing context free grammars, it is more common in attribute grammars
  132. (different alternatives have different attributes) and unavoidable in
  133. affix grammars (some affixes are an inherent part of the left hand
  134. side).  I'm afraid an ugly hack might be necessary to repair this.
  135. 6) From Andreas Maassen (maassen@zeus.informatik.rwth-aachen.de)
  136. The default value for nonterminal didn't work. The problem was that an
  137. initial "<" was read before the default values were initialised, so that
  138. it was read as a character, and not as a command. This has now been
  139. repaired.
  140. I had also forgotten to put "$"'s round the default values, so rather
  141. than producing "<" and ">", the default was an upside down "!" and an
  142. upside down "?". This has also been repaired.
  143.